﻿using System;
using System.IO;
using System.Configuration;
using System.Web;
using Db4objects.Db4o;
using Db4objects.Db4o.Config;
using Microsoft.Practices.ServiceLocation;
using KandaAlpha.Domain.Repository;

namespace KandaAlpha.Infrastructure.Repository.db4o
{
    public class Db4oHttpModule : IHttpModule
    {

        public Db4oHttpModule()
        {

        }

        public void Init(HttpApplication application)
        {
            application.EndRequest += new EventHandler(Application_EndRequest);
        }

        private void Application_EndRequest(object sender, EventArgs e)
        {
            ServiceLocator.Current.GetInstance<IRepositoryContext>().Terminate();
        }

        public void Dispose()
        {
        }

    }
}

